package com.leyou.item.client;

import com.leyou.common.dto.PageDTO;
import com.leyou.item.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@FeignClient("item-service")
public interface ItemClient {

    //spu分页查询
    @GetMapping("/goods/spu/page")
    PageDTO<SpuDTO> querySpuByPage(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                   @RequestParam(value = "rows", defaultValue = "5") Integer rows,
                                   @RequestParam(value = "saleable", required = false) Boolean saleable,
                                   @RequestParam(value = "categoryId", required = false) Long categoryId,
                                   @RequestParam(value = "brandId", required = false) Long brandId,
                                   @RequestParam(value = "id", required = false) Long id);



    //根据spuId查询对应的sku集合
    @GetMapping("/goods/sku/of/spu")
    List<SkuDTO> querySkuBySpuId(@RequestParam("id") Long id);

    //根据商品id（spuId）查询对应的规格参数组集合以及组内参数的信息，及对应值
    @GetMapping("/goods/spec/value")
    List<SpecParamDTO> querySpecsValues(
            @RequestParam("id") Long id, @RequestParam(value = "searching", required = false) Boolean searching);

    //根据品牌id集合查询对应的品牌集合
    @GetMapping("/brand/list")
    List<BrandDTO> listBrandByIds(@RequestParam("ids") List<Long> ids);
    //根据id的查询商品分类

    //根据分类id集合查询对应的分类集合
    @GetMapping("/category/list")
    List<CategoryDTO> listCategoryByIds(
            @RequestParam("ids") List<Long> ids);


    //根据id查询品牌
    @GetMapping("/brand/{id}")
    BrandDTO queryBrandById(@PathVariable("id") Long id);

    //根据id的查询商品分类
    @GetMapping("/category/{id}")
    CategoryDTO queryCategoryById(@PathVariable("id") Long id);

    //根据id查询spu，不包含别的
    @GetMapping("/goods/spu/{id}")
    SpuDTO querySpuById(@PathVariable("id") Long id);

    //根据spuId查询对应的spuDetail
    @GetMapping("/goods/spu/detail")
    SpuDetailDTO querySpuDetailById(@RequestParam("id") Long spuId);


    // 根据分类id查询规格组及组内参数
    @GetMapping("/spec/list")
    List<SpecGroupDTO> querySpecList(@RequestParam("id") Long id);

}
